package com.ntschy.common.valid.date;


import cn.hutool.core.util.StrUtil;

import java.util.regex.Pattern;

public class DateValidationUtil {

    private static final Pattern PATTERN = Pattern.compile("^((?!0000)[0-9]{4}-((0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-8])|(0[13-9]|1[0-2])-(29|30)|(0[13578]|1[02])-31)|([0-9]{2}(0[48]|[2468][048]|[13579][26])|(0[48]|[2468][048]|[13579][26])00)-02-29)$");
    /**
     * 验证日期格式 2020-01-01
     */
    public static boolean isDate(String date){
        if (StrUtil.isEmpty(date)) {
            return false;
        } else {
            boolean matches = PATTERN.matcher(date).matches();
            return matches;
        }
    }

}
